﻿@model Tuple<Mvc4.Models.ShowModel,IEnumerable<Mvc4.Models.EpisodeModel>>

@{
    ViewBag.Title = "Detail";
}

<h2>Show Details</h2>
 <fieldset>
        <legend>Show</legend>
@Html.DisplayFor(f=>f.Item1)
</fieldset>
@if(Model.Item2!=null && Model.Item2.Any()){
<table>
<thead>
<tr>
<th></th><th>@Html.LabelFor(e=>e.Item2.FirstOrDefault().Season)</th>
<th>@Html.LabelFor(e=>e.Item2.FirstOrDefault().EpisodeNumber)</th>
<th>@Html.LabelFor(e=>e.Item2.FirstOrDefault().EpisodeName)</th>
<th>@Html.LabelFor(e=>e.Item2.FirstOrDefault().LastWatched)</th>
</tr>
</thead>
<tbody>
@foreach (var e in Model.Item2.OrderBy(i=>i.Season).ThenBy(i=>i.EpisodeNumber))
{
<tr>
<td>@Html.ActionLink("Edit",MVC.Episode.Edit(e.EpisodeID))</td>
<td>@Html.DisplayFor(ep=>e.Season)</td>
<td>@Html.DisplayFor(ep=>e.EpisodeNumber)</td>
<td>@Html.DisplayFor(ep=>e.EpisodeName)</td>
<td>@Html.DisplayFor(ep=>e.LastWatched)</td>
</tr>
}
</tbody>
</table>
}